'use strict';
/* jshint mocha: true */
var path = require('path');
var expect = require('chai').expect;
var Injector = require('../');
var examplePath = path.resolve(__dirname, '../example');

describe('test-inject', function () {
    it('It should has return loaded module', function () {
        var injector = new Injector([examplePath], {
            'types/type2': 123
        });
        expect(function () {
            injector.inject(Injector.define(['types/type3'], function () {}));
        }).to.throw(Error);
        expect(injector.inject(Injector.define(['types/type2'], function (type2) {return type2;}))).to.equal(123);
    });
    it('It should has injected correct recursive dependencies value', function () {
        var injector = new Injector([examplePath]);
        injector.inject(Injector.define(['recursive/entityA', 'recursive/entityB', 'recursive/entityC', 'recursive/entityD'], function (entityA, entityB, entityC, entityD) {
            expect(entityA).to.equal(1+entityB);
            expect(entityB).to.equal(2+entityC+entityD);
            expect(entityC).to.equal(4+entityD);
            expect(entityD).to.equal(8);
        }));
    });
});